/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package facade;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import modelo.Produto;
import modelo.Titulo;

/**
 *
 * @author andre
 */
@Stateless
public class TituloFacade extends AbstractFacade<Titulo> {
    @PersistenceContext(unitName = "academiawebPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public TituloFacade() {
        super(Titulo.class);
    }
    
    public Integer getMaxIdTitulo(){
        int retorno = 1;
        Query cq = getEntityManager().createNamedQuery("Titulo.maxIdTitulo");
        if (cq.getResultList().get(0) != null){
            retorno = (Integer) cq.getResultList().get(0);
        }
        
        return retorno;
    }
    
}
